-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Add AmericanFlagSort algorithm #6662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add AmericanFlagSort algorithm #6662
Conversation
- Implements American Flag Sort using bucket-based radix sort approach - Includes comprehensive test suite extending SortingAlgorithmTest - Follows project coding standards and documentation style
- Replace radix-based approach with generic bucket partitioning - Handle all data types: integers, floats, strings, custom objects - Support edge cases: NaN, Infinity, empty strings, mixed values - Use insertion sort for small arrays for better performance - Maintains O(n log n) average case complexity
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6662 +/- ##
============================================
+ Coverage 76.60% 76.65% +0.04%
- Complexity 6026 6043 +17
============================================
Files 719 720 +1
Lines 20326 20369 +43
Branches 3937 3946 +9
============================================
+ Hits 15571 15613 +42
Misses 4164 4164
- Partials 591 592 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Remove trailing spaces from lines 16, 30, 55, 59, 70, 80 - Improve code formatting for checkstyle compliance - Maintain same functionality and logic
- Change double spaces to single spaces before inline comments - Lines 56-58: Adjust comment spacing to match clang-format requirements - Maintain code readability and functionality
The CodeQL workflow failed due to a flaky BloomFilterTest, not related to AmericanFlagSort code. This empty commit triggers a re-run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure that this is american flag sort? The current implementation looks like a 3-way QuickSort (Dutch National Flag), not a true American Flag Sort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding explicit test cases for small arrays, already sorted arrays, reverse-sorted arrays, duplicates, and empty arrays to ensure correctness. You may want to add tests for null arrays or arrays with a single element to confirm that the algorithm handles these gracefully.
clang-format -i --style=file path/to/your/file.java